import logging
import platform

BASE_PATH = ""
if platform.system().lower() == 'windows':
    print("windows 环境")
    BASE_PATH = "E:\gengxuelong_study\server_local_adapter\\ai\wenet_gxl\\"
elif platform.system().lower() == 'linux':
    print("linux 环境")
    BASE_PATH = "/home/work_nfs7/xlgeng/code_runner_gxl/ai/wenet_gxl/"
DATA_PATH = BASE_PATH + "data/"
OUTPUT_PATH = BASE_PATH + "output/"
LOG_PATH = OUTPUT_PATH + "log/"


def AI_LOGGER(log_file_path=LOG_PATH + "wenet_gxl.log"):
    """
    将日志输出到日志文件和控制台
    """
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)
    formatter = logging.Formatter(
        '%(asctime)s - %(levelname)s - %(message)s')
    from ai.utils.utils_file import makedir_for_file
    makedir_for_file(log_file_path)
    # 创建一个handler，用于写入日志文件
    file_handler = logging.FileHandler(
        filename=log_file_path)
    file_handler.setFormatter(formatter)
    file_handler.setLevel(logging.INFO)
    logger.addHandler(file_handler)
    # 创建一个handler，用于将日志输出到控制台
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    console.setFormatter(formatter)
    logger.addHandler(console)
    return logger


gxl_logger = AI_LOGGER()
